package han.util;

import han.entity.FinanceProjectLabelEntity;
import han.sql.Operator;

import java.io.BufferedReader;
import java.io.FileReader;
import java.sql.Timestamp;
import java.util.Objects;

/**
 * @author: Han
 * @date: 2018/7/13 14:21
 * @dscription: 载入本地数据到数据库
 */
public class LoadInfo {

    public static void main(String... args) {
        loadTypeFile();
    }

    /**
     * 载入融资项目所有分类
     */
    private static void loadTypeFile() {
        Operator operator = Operator.getInstance();
        BufferedReader reader = null;
        try {
            reader = new BufferedReader(new FileReader("F:\\数据\\36ke\\融资项目所有分类.txt"));
            String line;
            while ((line = reader.readLine()) != null) {
                FinanceProjectLabelEntity entity = new FinanceProjectLabelEntity();
                entity.setLabel(line);
                entity.setTotalPages(-1);
                entity.setCurrentPage(1);
                entity.setLastRequestTime(new Timestamp(System.currentTimeMillis()));
                operator.insertFinanceProjectLabel(entity);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                Objects.requireNonNull(reader).close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
